package com.guchenbo.flink;

import com.guchenbo.datagen.common.Person;
import com.guchenbo.datagen.common.PersonSupplier;
import org.apache.flink.streaming.api.functions.source.SourceFunction;

/**
 * @author guchenbo
 * @date 2024/6/10
 */
public class PersonSource implements SourceFunction<Person> {
    @Override
    public void run(SourceContext<Person> ctx) throws Exception {
        System.out.println("PersonSource run");
        PersonSupplier personSupplier = new PersonSupplier();
        for (int i = 0; i < 10; i++) {
            ctx.collectWithTimestamp(personSupplier.get(), System.currentTimeMillis());
        }
    }

    @Override
    public void cancel() {

    }
}
